<?php
namespace SYSTEM\HELPERS;

class Url {
    
    public function getUrl($str) {
        return $this->getUrlProtocol()."://".$_SERVER['HTTP_HOST']. substr($_SERVER['SCRIPT_NAME'], 0, -strlen("index.php")).$str;
    }
    
    public function getUrlProtocol() {
        if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ||
                $_SERVER['SERVER_PORT'] == \SYSTEM\ConfigsManager::$configs['general']['https_port']) {
            $protocol = "https";
        } else {
            $protocol = "http";
        }
        return $protocol;
    }
}